package com.student.controller;

import com.student.VO.SnackVO;
import com.student.VO.productPageVO;
import com.student.dto.ResponseDto;
import com.student.pojo.Carousel;
import com.student.pojo.SnackGoods;
import com.student.service.SnackGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: makeups
 * @BelongsPackage: com.student.controller
 * @Author: 小徐
 * @CreateTime: 2024-12-19 22:53
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("goods")
public class SnackGoodsController {
    @Autowired
    public SnackGoodsService snackGoodsService;

    @RequestMapping("getAllSnack")
    public ResponseDto getAllSnack(@RequestBody SnackVO product) {
        System.err.println(product);
        return snackGoodsService.getAllSnack(product);
    }

    //  获取所有的类型
    @RequestMapping("getSnackType")
    public ResponseDto getSnackType() {
        return snackGoodsService.getSnackType();
    }

    //  修改信息
    @RequestMapping("updateGoods")
    public ResponseDto updateGoods(@RequestBody SnackGoods updateProduct) {
        System.err.println(updateProduct);
        return snackGoodsService.updateGoods(updateProduct);
    }

    //删除信息
    @RequestMapping("deleteProduct")
    public ResponseDto deleteProduct(@RequestParam("id") Integer id) {
        return snackGoodsService.deleteProduct(id);
    }

    @RequestMapping("addGoods")
    public ResponseDto addGoods(@RequestBody SnackGoods product) {
        System.err.println(product);
        return snackGoodsService.addGoods(product);
    }

    //  用户前端获取所有商品
    @RequestMapping("getAllproduct")
    public ResponseDto getAllproduct(@RequestBody productPageVO productPage) {
        System.out.println(productPage);
        return snackGoodsService.getAllproduct(productPage);
    }


    @RequestMapping("getAllproductSales")
    public ResponseDto getAllproductSales(@RequestBody productPageVO productPage) {
        System.out.println(productPage);
        return snackGoodsService.getAllproductSales(productPage);
    }

    //请求单个商品
    @RequestMapping("SingleSnack")
    public ResponseDto SingleSnack(@RequestParam("id") Integer id) {
        return snackGoodsService.SingleSnack(id);
    }


    //    用户渲染轮播图
//    用户渲染轮播图
    @RequestMapping("getCarousel")
    public ResponseDto getCarousels() {
        return snackGoodsService.getCarousels();
    }


    //  后端管理轮播图
    @RequestMapping("getAllCarousel")
    public ResponseDto getCarousel(@RequestBody Carousel productPage) {
        return snackGoodsService.getCarousel(productPage);
    }

    //   删除轮播i图
    @RequestMapping("deleteCarouse")
    public ResponseDto deleteCarouse(@RequestParam("id") Integer id) {
        return snackGoodsService.deleteCarouse(id);
    }

    //添加 轮播图
    @RequestMapping("addCarousel")
    public ResponseDto addCarousel(@RequestBody Carousel productMessage) {

        return snackGoodsService.addCarousel(productMessage.getProductImage());

    }

}